package zero.tech.games.gate.controller;

import java.text.ParseException;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import zero.tech.core.data.Resp;
import zero.tech.core.data.SimpleUser;
import zero.tech.core.util.DatetimeUtil;
import zero.tech.games.gate.service.api.IExtensionService;

@RestController
public class ExtensionController extends BaseController{
	@Autowired
	private IExtensionService extensionService;
	@RequestMapping(value = "/extension-reward")
	public Resp extensionReward(HttpServletRequest request, @RequestBody Map<String, Object> map) throws ParseException  {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return extensionService.extensionReward(simpleUser, club_id,begin,end);
	}
	
	@RequestMapping(value = "/extension-reward-get")
	public Resp extensionRewardGet(HttpServletRequest request, @RequestBody Map<String, Object> map) throws ParseException  {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		long gold=Long.valueOf(map.get("gold").toString());
		return extensionService.extensionRewardGet(simpleUser, club_id,gold);
	}
}
